<template>
	<view class="cantainer">
		<fui-card  :title="thisGreenLand.name" size="35">
			<view class="fui-card__content">
				 <u-swiper :list="swiperList" class="fui-cover" mode="aspectFill" height="200"></u-swiper>
			</view>
		</fui-card>
		<fui-card >
			<view class="fui-card__content">
				<view class="text-content">
					<view class="text-title">
						<text>绿地名称： <text v-text="thisGreenLand.name"></text></text>
					</view>
					<view class="text-title">
						<text>绿地编号： <text v-text="thisGreenLand.interNum"></text></text>
					</view>
					<view class="text-title">
						<text>绿地等级： <text v-text="thisGreenLand.grade"></text></text>
					</view>
					<view class="text-title">
						<text>绿地面积： <text v-text="thisGreenLand.area+'平方米'"></text></text>
					</view>
				</view>
				<view class="split">
					<view class="color"> &nbsp;</view>植物信息
				</view>
				<view class="text-content" v-for="(item,index) in thisGreenLand.sufferInjuries">
					<view class="text-title"> 
						<text>植物名称： <text v-text="item.name"></text></text>
					</view>
					<view class="text-title">
						<text>植物健康水平： <text v-text="item.healthy+'%'"></text></text>
					</view>
					<view class="text-title">
						<text>植物面积： <text v-text="item.area+'平方米'"></text></text>
					</view>
					<view class="split">
						<view class="color"> &nbsp;</view>病虫信息
					</view>
					<view class="text-content" v-for="(Pestsitem,Pestsindex) in item.pests">
						<view class="text-title"> 
							<text>病虫名称： <text v-text="Pestsitem.name"></text></text>
						</view>
						<view class="text-title">
							<text>病虫类型： <text v-text="Pestsitem.type"></text></text>
						</view>
						<view class="text-title">
							<text>病虫数量： <text v-text="Pestsitem.number+'只'"></text></text>
						</view>
					</view>
					<view class="split">
						<view class="color"> &nbsp;</view>病毒信息
					</view>
					<view class="text-content" v-for="(Virusitem,Virusindex) in item.virus">
						<view class="text-title"> 
							<text>病毒名称： <text v-text="Virusitem.name"></text></text>
						</view>
						<view class="text-title">
							<text>病毒规模： <text v-text="Virusitem.number"></text></text>
						</view>
					</view>
				</view>
				
				
			</view>
		</fui-card>
	</view>
</template>

<script>
	import {saveImageToPhotosAlbum} from "../../common/utils/saveImage.js"
	export default {
		data() {
			return {
				swiperList:[],
				user:[],
				thisGreenLand:[]
			}
		},
		onLoad(options) {
			//page/messageUp/messageUp历史信息页面跳转
			if(options.id != null ){
				this.initDate(options.id)
				this.showPhoto()
			}
			//pages/riskResponse/riskResponse.vue风险响应页面跳转
			if(options.greenLandId != null){
				console.log(options.greenLandId)
				this.greenLandDetails(options.greenLandId)
			}
			// console.log(this.swiperList)
		},
		methods: {
			initDate(id){
				if(this.$storage.get("user") != []){
					this.thisGreenLand=[]
					this.user= JSON.parse( this.$storage.get("user"))
					for(let i=0;i<this.user.greenLands.length;i++){
						if(this.user.greenLands[i].interNum == id){
							this.thisGreenLand=this.user.greenLands[i]
							break
						}
					}
				}
			},
			greenLandDetails(id){
				if(this.$storage.get("greenLandAll") != []){
					this.thisGreenLand=[]
					let all = this.$storage.get("greenLandAll")
					all.forEach(item=>{
						if(item.id == id){
							console.log(item)
							this.thisGreenLand=item
							item.greenLandPhotos.forEach(photo=>{
								this.swiperList.push(photo.photoUrl)
							})
						}
					})
				}
			},
			showPhoto(){
				this.thisGreenLand.greenLandPhotos.forEach((item,index)=>{
					this.swiperList.push(item.photoUrl)
					console.log(item)
				})
			}
		}
	}
</script>

<style scoped lang="scss">
.cantainer{
	margin: 20rpx;
}
.fui-cover{
	border-radius: 20px;
	height: 200rpx;
}
.text-content{
	margin-top: 20rpx;
	box-shadow:5 5 5 #000000;
	.text-title{
		margin: 10rpx;
		color: #8b8b8b;
	}
}
.split{
	margin: 50rpx 20rpx;
	color:#3b4244 ;
	font-weight: bold;
	.color{
		display: inline-block;
		width: 8rpx;
		height: 25rpx;
		background-color: #348669;
		margin-right: 5rpx;
	}
}
</style>
